{% extends "RegardProductsBundle::layout.html.twig" %}

{# redefine errors theme #}
{% block form_errors %}
{% spaceless %}
    {% if errors|length > 0 %}
        {% for error in errors %}
        <span class="form_error">&nbsp;&nbsp;{{ error.message }}</span>
        {% endfor %}
    {% endif %}
{% endspaceless %}
{% endblock form_errors %}

{% block content %}

<div id="ADMIN_ADD_EDIT">
    <div class="div_add_edit_title">
        <span class="div_title">
			{% if product.id %}
				{{ 'Edition d\'un produit' }}
			{% else %}
				{{ 'Ajout d\'un produit' }}
			{% endif %}
		</span>
    </div>
          
    <div id="notice">
        {% for flashMessage in app.session.flashbag.get('notice') %}
            {{ flashMessage }}
        {% endfor %}
    </div>
		
    <div class="add_edit_form">
		<form action="{% if product.id %}{{ path('regard_products_edit', {'productId':product.id}) }}{% else %}{{ path('regard_products_add', {'brandId':brandId}) }}{% endif %}" method="post" {{ form_enctype(form) }}>
			
			<div class="div_input_text">
				<span>{{ form_label(form.name, 'Nom') }}</span>
				<span class="error">{{ form_errors(form.name) }}</span><br />
				{{ form_widget(form.name) }}
			</div>
			<div class="div_input_text">
				<span>{{ form_label(form.description, 'Description') }}</span>
				<span class="error">{{ form_errors(form.description) }}</span><br />
				{{ form_widget(form.description) }}
			</div>
			<div class="div_input_text">
				<span>{{ form_label(form.picture, 'Image') }}</span>
				<span class="error">{{ form_errors(form.picture) }}</span><br />
				{{ form_widget(form.picture) }}
				&nbsp;<span class="picture_dimension">taille 125x110</span>
			</div>
			<div class="div_input_text">
				{{ form_widget(form.brandId, {value: brandId}) }}
			</div>

			<div class="div_submit">
				<input type="submit" id="submit" value="{% if product.id %}{{ 'Enregistrer' }}{% else %}{{ 'Ajouter' }}{% endif %}" name="submit" />
				<span>&nbsp;<a href="{{ path('regard_list_products', {'brandId':brandId}) }}">Annuler</a></span>
			</div>
			
			{{ form_rest(form) }}
		</form>
    </div>
</div>

{% endblock %}
